<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var findAnagrams = function (s, p) {
            let res = []
            for(let i=0;i<=s.length-p.length;i++){
                let str = s.slice(i,i+p.length).split('').sort().join('')
                if(str === p){
                    res.push(i)
                }
            }
            return res
        };
    </script>
</body>

</html>